package com.hfh.thread;

/**
 * @Author hfh
 * @Date 2022 09 15 20 03
 **/
public class Test extends Thread{
//    volatile boolean flag = true;

    public static void main(String[] args) throws InterruptedException {
        Test t = new Test();
        t.setDaemon(true);
        t.start();
        for (int i=1;i<=100;i++){
            if (i%2==0){
                System.out.println("偶数："+i);
            }
        }
        t.interrupt();
//        t.flag = false;
//        t.join();
        /*for (int i=1;i<=100;i++){
            if (i%2==0){
                System.out.println("偶数："+i);
            }
        }*/

    }

    @Override
    public void run() {
        while (!isInterrupted()){
            System.out.println("运行。。。");
        }

       /* while (flag){
            System.out.println("运行。。。");
        }*/
        /*for (int i=1;i<=200;i++){
            if (i%2!=0){
                try {
                    Thread.sleep(100);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("奇数："+i);
            }
        }*/
    }
}
